﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
namespace DA
{
    public class Room_DAL : clsConnect
    {
        private clsConnect cls = new clsConnect();
        #region[Get-Data]
        public DataTable GetRoom()
        {
            return cls.GetData("sp_tb_Room_Search");
        }
        public DataTable GetRoomWareHouse(int id)
        {
            return cls.GetData_ID_Int("sp_tb_Room_Warehouse", "@Warehouse_Id", id);
        }
        public DataTable GetRoomDetail_Edit(int id)
        {
            return cls.GetData_ID_Int("sp_tb_Room_Detail_Edit", "@Room_Id", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertRoom(ET.Room_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Room_Alias", data.Room_Alias);
            cls.AddParameter("@Warehouse_Id", data.Warehouse_Id);
            cls.AddParameter("@Room_Name", data.Room_Name);
            cls.AddParameter("@Room_Tankage", data.Room_Tankage);
            cls.AddParameter("@Unit_Id", data.Unit_Id);
            cls.ExecuteNonQuery("sp_tb_Room_Insert");
            return true;
        }
        public bool UpdateRoom(ET.Room_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Room_Id", data.Room_Id);
            cls.AddParameter("@Warehouse_Id", data.Warehouse_Id);
            cls.AddParameter("@Room_Alias", data.Room_Alias);
            cls.AddParameter("@Room_Name", data.Room_Name);
            cls.AddParameter("@Room_Tankage", data.Room_Tankage);
            cls.AddParameter("@Unit_Id", data.Unit_Id);
            cls.ExecuteNonQuery("sp_tb_Room_Update");
            return true;
        }
        public bool DeleteRoom(int id)
        {
            cls.Delete("sp_tb_Room_Delete", "@Room_Id", id);
            return true;
        }
        #endregion

        #region[Search-Fillter]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_tb_Room_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}
